/*
  This file is part of 'Trivial chess'.

  'Trivial chess' is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  'Trivial chess' is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with 'Trivial chess'.  If not, see <http://www.gnu.org/licenses/>.
*/

/* SVN FILE: $Id$ */
/**
 * @author         $Author$
 * @version        $Rev$
 * @lastrevision   $Date$
 * @filesource     $URL$
 */

#ifndef RANKORD_H_
#define RANKORD_H_

#include <boost/cstdint.hpp>

#include "RankAbstract.h"

template<typename Int = int8_t>
class RankOrd : public RankAbstract<RankOrd, Int> {
public:
	static const RankOrd<Int> R1() { return RankOrd<Int>(0); }
	static const RankOrd<Int> R2() { return RankOrd<Int>(1); }
	static const RankOrd<Int> R3() { return RankOrd<Int>(2); }
	static const RankOrd<Int> R4() { return RankOrd<Int>(3); }
	static const RankOrd<Int> R5() { return RankOrd<Int>(4); }
	static const RankOrd<Int> R6() { return RankOrd<Int>(5); }
	static const RankOrd<Int> R7() { return RankOrd<Int>(6); }
	static const RankOrd<Int> R8() { return RankOrd<Int>(7); }

	static const RankOrd<Int> NIL()  { return RankOrd<Int>(8); }
	static const RankOrd<Int> END()  { return RankOrd<Int>::NIL(); }
	static const RankOrd<Int> REND() { return RankOrd<Int>(-1); }
public:
	RankOrd<Int>() {}

	explicit RankOrd<Int>(const Int rank) : rank(rank)  {}
	explicit RankOrd<Int>(const std::string str)  { this->me().fromStr(str); }

	Int toInt() const {
		return this->rank;
	}

	void fromInt(const Int rank) {
		this->rank = rank;
	}

	RankOrd<Int> operator++() {
		return RankOrd<Int>(++this->rank);
	}

	RankOrd<Int> operator--() {
		return RankOrd<Int>(--this->rank);
	}

	bool operator==(const RankOrd<Int> rank) const {
		return  this->rank == rank.rank;
	}

private:
	Int rank;
};



#endif /* RANKORD_H_ */
